

#ifndef __AT32F403A_407_BOARD_H
#define __AT32F403A_407_BOARD_H

#ifdef __cplusplus
extern "C" {
#endif

#include "stdio.h"
#include "at32f403a_407.h"
#include "at32f403a_407_clock.h"

//User Inc
#include "can.h"
#include "spi.h"
#include "adc.h"
#include "tim.h"
#include "leg_msg.h"



/**************** define led ******************/
#define LED_PIN                         GPIO_PINS_3
#define LED_GPIO                        GPIOA
#define LED_GPIO_CRM_CLK                CRM_GPIOA_PERIPH_CLOCK


/**************** define print uart ******************/
#define PRINT_UART                       USART1
#define PRINT_UART_CRM_CLK               CRM_USART1_PERIPH_CLOCK
#define PRINT_UART_TX_PIN                GPIO_PINS_9
#define PRINT_UART_TX_GPIO               GPIOA
#define PRINT_UART_TX_GPIO_CRM_CLK       CRM_GPIOA_PERIPH_CLOCK



/**
  * @}
  */

/** @defgroup BOARD_exported_functions
  * @{
  */

/******************** functions ********************/
void at32_board_init(void);
void LED_Init(void);
void LED_ON(void);
void LED_OFF(void);



/* delay function */
void delay_init(void);
void delay_us(uint32_t nus);
void delay_ms(uint16_t nms);
void delay_sec(uint16_t sec);
uint16_t  float_to_uint(float v,float v_min,float v_max,uint32_t width);
float Constraint(float Value,float Min,float Max);
/* printf uart init function */
void uart_print_init(uint32_t baudrate);


#ifdef __cplusplus
}
#endif

#endif

